package com.wx.app.spacewhisper.controller;
import com.wx.app.spacewhisper.entity.Whisper;
import com.wx.app.spacewhisper.service.WhisperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = {"吐槽接口"})
@RestController
@RequestMapping("/api/whisper")
public class WhisperController {

    @Autowired
    WhisperService whisperService;

    @ApiOperation(value = "发布吐槽接口", notes = "发布吐槽")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "content", value = "吐槽内容", required = true),
            @ApiImplicitParam(name = "token", value = "token", required = false)

    })
    @PostMapping("/insertWhisper")
    public int insertWhisper(String content,
                             @RequestHeader("token") @ApiIgnore String token){
        return whisperService.insertWhisper(content,token);
    }

    
    @ApiOperation(value = "查找吐槽接口", notes = "通过id查找吐槽")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "吐槽id", required = true)
    })
    @GetMapping("/selectWhisperById")
    public Whisper selectWhisperById(Integer id){
        return whisperService.selectWhisperById(id) ;
    }

}

